//
//  PosterFirstCell.m
//  IComic_Stone
//
//  Created by 琳琳 on 15-3-23.
//  Copyright (c) 2015年 lanou3g.com 蓝鸥科技. All rights reserved.
//

#import "PosterFirstCell.h"
#import "PosterCollectionViewCell.h"
@implementation PosterFirstCell

-(void)dealloc
{
    //[_posterImageView release];
    //[_posterLabel release];
    [_posterArr release];
    [_posterCollectionView release];
    [super dealloc];
}
-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {

       
        
        
        self.flowLayout = [[UICollectionViewFlowLayout alloc] init];
        self.flowLayout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
//        self.flowLayout.itemSize = CGSizeMake(self.contentView.frame.size.width , self.contentView.frame.size.height);
//        flowLayout.itemSize = CGSizeMake(310, 150);
        self.flowLayout.minimumLineSpacing = 20;
        self.flowLayout.sectionInset = UIEdgeInsetsMake(10, 10, 10, 10);

        self.posterCollectionView = [[UICollectionView alloc] initWithFrame:CGRectMake(0, 0, 0, 0) collectionViewLayout:self.flowLayout];
        [_flowLayout release];
        self.posterCollectionView.delegate = self;
        self.posterCollectionView.dataSource = self;
        //关闭显示的滚动条
        self.posterCollectionView.showsHorizontalScrollIndicator = NO;
        //按页数翻
        self.posterCollectionView.pagingEnabled = YES;
        //圆角
        self.posterCollectionView.layer.cornerRadius = 30;
        self.posterCollectionView.backgroundColor = [UIColor cyanColor];
        [self.contentView addSubview:self.posterCollectionView];
        [_posterCollectionView release];

        [self.posterCollectionView registerClass:[PosterCollectionViewCell class] forCellWithReuseIdentifier:@"reuse2"];

        
//        
//        //滚动图片
//        self.posterImageView = [[UIImageView alloc] init];
//        self.posterImageView.backgroundColor = [UIColor redColor];
//        self.posterImageView.layer.cornerRadius = 30;
//        [self.contentView addSubview:self.posterImageView];
//        [_posterImageView release];
//        
//        self.posterLabel = [[UILabel alloc] init];
//        self.posterLabel.backgroundColor = [UIColor blueColor];
//        [self.contentView addSubview:self.posterLabel];
//        [_posterLabel release];
    }
    return self;
}



- (void)layoutSubviews
{
    [super layoutSubviews];
    CGFloat wight = self.contentView.frame.size.width;
    CGFloat height = self.contentView.frame.size.height;
//    self.PosterImageView.frame = CGRectMake(10, 10, wight  - 20, height - 50);
//   self.PosterLabel.frame = CGRectMake(10, 10, wight  - 20, height - 20);

    //flowLayout的大小
    self.flowLayout.itemSize = CGSizeMake(self.contentView.frame.size.width - 60, self.contentView.frame.size.height - 40);
    //collectionView 的大小
    self.posterCollectionView.frame = CGRectMake(20, 10, wight - 40, height - 20);

}
//cell的数量
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
    return 10;
}
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    PosterCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"reuse2" forIndexPath:indexPath];
    cell.backgroundColor = [UIColor whiteColor];
    return cell;
}
- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
